#include <QtGui/QApplication>
#include "Login.h"
#include "user.h"
#include "admindata.h"
#include <QFile>
#include <QDataStream>
#include <QDebug>

static QString FILE_NAME = "Data.dat";

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    DateRange semDuration;
    QVector<DateRange> daysOff;
    QVector<OutlineSection> outlineSections;
    QVector<Course> courses;
    QVector<Professor> profs;
    QVector<User> users;

    AdminData data(semDuration, daysOff, outlineSections, courses, profs, users);
    QFile file(FILE_NAME);
    if (file.exists())
    {
        file.open(QIODevice::ReadOnly);
        QDataStream in (&file);
        in >> data;
        file.close();
    }

    Login* w = new Login(0, &data);
    w->show();

    int exitCode = a.exec();

    file.open(QIODevice::WriteOnly);
    QDataStream out(&file);
    out << data;
    file.close();

    return exitCode;
}
